Skip to content

Conversation

@mdrxy
Copy link
Member

@mdrxy mdrxy commented Nov 16, 2025

Introduces an automated system to detecting and manage incorrect imports from langchain_core in favor of using the re-exports from langchain.

  • Added check-import-mappings.yml workflow to periodically analyze the latest version of langchain_core, check for re-exports in langchain (and generate import_mappings.json), and automatically create PRs to update the mappings cache in this repo.
  • Added check_import_mappings.py to fetch latest package releases, introspect langchain public __init__ files, and generate a detailed mapping of re-exported members from langchain_core. Uses the previous local import_mappings.json
  • Added check-pr-imports.yml workflow to run on PRs, ensuring inbound contributions use langchain imports when available, and comment on PRs with specific guidance if issues are found.
    • Uses check_pr_imports.py to analyze PR diffs against the import mappings, detect incorrect langchain_core imports, and output suggested fixes for contributors.

@github-actions github-actions bot added python For content related to the Python version of LangChain projects docs-infra ci tests labels Nov 16, 2025
@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-mdrxyi-1763261349-1c07824

@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-mdrxyi-1763262755-71dcb2a

@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-mdrxyi-1763263038-d1e9709

@mdrxy mdrxy requested a review from eyurtsev November 16, 2025 06:03
@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-mdrxyi-1763797132-816b00c

@mdrxy mdrxy requested a review from Copilot November 22, 2025 07:52
Copilot finished reviewing on behalf of mdrxy November 22, 2025 07:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an automated system to detect incorrect imports from langchain_core that should use re-exports from langchain. The implementation includes two Python scripts for analyzing and checking imports, comprehensive unit tests, and GitHub Actions workflows for continuous validation.

Key changes:

  • Automated detection of langchain_core re-exports available through langchain
  • PR validation workflow that comments on pull requests with import issues
  • Scheduled workflow to keep import mappings up-to-date

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/unit_tests/test_check_pr_imports.py Comprehensive unit tests for the PR import checker, covering diff parsing, import line validation, and mapping dictionary construction
scripts/check_pr_imports.py Main script that analyzes PR diffs to identify incorrect langchain_core imports and suggests langchain alternatives
scripts/check_import_mappings.py Script that introspects the latest langchain package to build a mapping of available re-exports from langchain_core
scripts/__init__.py Package initializer for the scripts module
.github/workflows/check-pr-imports.yml GitHub Actions workflow that runs on PRs to validate imports and comment with suggestions
.github/workflows/check-import-mappings.yml Scheduled workflow that periodically updates import mappings and creates PRs with changes

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-mdrxyi-1763846662-d758e34

@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-mdrxyi-1763848469-6d4c979

@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-mdrxyi-1763849557-d2dee40

@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-mdrxyi-1763849963-0ef804a

Copilot finished reviewing on behalf of mdrxy November 22, 2025 22:21
@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-mdrxyi-1763850090-c846f9d

@mdrxy mdrxy changed the title feat(infra): validate imports from langchain feat(ci): validate imports from langchain Nov 22, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

diff = """diff --git a/test.py b/test.py
index 1234567..abcdefg 100644
--- a/test.py
+++ b/test.py
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff in the test case contains a line with 0 for the line number (line 226 shows +++ b/test.py followed by line 0). This doesn't match the actual diff format. While tests pass, the line numbering in the multiline string should represent realistic diff output for better test clarity and maintainability.

Copilot uses AI. Check for mistakes.
diff = """diff --git a/file1.py b/file1.py
index 1234567..abcdefg 100644
--- a/file1.py
+++ b/file1.py
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the previous test, the diff contains line number 0 (after +++ b/file1.py on line 249). While the tests work, this doesn't represent actual git diff output accurately, which could confuse future maintainers.

Copilot uses AI. Check for mistakes.
diff --git a/file2.py b/file2.py
index 2345678..bcdefgh 100644
--- a/file2.py
+++ b/file2.py
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff contains line number 0 (after +++ b/file2.py on line 256). Consider using realistic diff formatting in test cases to improve maintainability and clarity.

Copilot uses AI. Check for mistakes.
diff = """diff --git a/test.py b/test.py
index 1234567..abcdefg 100644
--- a/test.py
+++ b/test.py
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff contains line number 0 (after +++ b/test.py on line 283). While functional, realistic diff formatting would improve test documentation.

Copilot uses AI. Check for mistakes.
diff = """diff --git a/test.py b/test.py
index 1234567..abcdefg 100644
--- a/test.py
+++ b/test.py
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff contains line number 0 (after +++ b/test.py on line 300). Consider using realistic diff formatting for better test documentation.

Copilot uses AI. Check for mistakes.
@mdrxy mdrxy merged commit 2745dc5 into main Nov 22, 2025
14 checks passed
@mdrxy mdrxy deleted the mdrxy/import-mappings branch November 22, 2025 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci docs-infra python For content related to the Python version of LangChain projects tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants